/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements.  See the NOTICE file
distributed with this work for additional information
regarding copyright ownership.  The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License.  You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied.  See the License for the
specific language governing permissions and limitations
under the License.
 */
package td.domain;

//Using ArrayLists directly because of GWT
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.HashSet;
import java.util.SortedSet;

import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Ignore;
import com.googlecode.objectify.annotation.Index;

/**
 * A thinker.
 * 
 * @author Artem Shamsutdinov
 */
@Entity
public class Thinker extends DatastoreObject {

	private static final long serialVersionUID = -2474813716664355068L;

	@Index
	private String email;
	@Index
	private String thinkerId;

	private String passwordDigest;

	private String sessionCode;

	private Date lastAccessDate;

	private Date joinedOnDate;

	private Date lastPublishedDate;

	private Long lastPublishedVersionId;

	private Date lastPublishedOlderVersionDate;

	private Long lastPublishedOlderVersionId;

	@Ignore
	Thought draft;

	@Ignore
	ArrayList<Thought> draftReferences;

	// IDs of Thinkers who read your thoughts.
	@Ignore
	HashSet<Long> reads;

	@Ignore
	HashMap<Long, TagThinker> tagsByThought;

	// a cache of active references
	@Ignore
	ArrayList<Thought> activeReferences;

	@Ignore
	SortedSet<Thought> thoughtsCronologically;

	@Ignore
	ArrayList<Topic> recentlyReadTopics;

	@Ignore
	ArrayList<Topic> recentlyWrittenToTopics;

	// FIXME: add this back in and figure out how to deal with Ref in GWT
	// @Load(GetPublishedThoughtIds.class)
	// private Ref<IdCache> recentPublishedThoughtIds;
	//
	// @Load(GetUnpublishedThoughtIds.class)
	// private Ref<IdCache> recentUnpublishedThoughtIds;

	public Thinker() {
		// No-arg constructor required by Objectify
	}

	public Thinker(String email, String thinkerId, String passwordDigest,
			Date joinedOn) {
		this.email = email;
		this.thinkerId = thinkerId;
		this.passwordDigest = passwordDigest;
		this.joinedOnDate = joinedOn;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getThinkerId() {
		return thinkerId;
	}

	public void setThinkerId(String thinkerId) {
		this.thinkerId = thinkerId;
	}

	public String getPasswordDigest() {
		return passwordDigest;
	}

	public void setPasswordDigest(String password) {
		this.passwordDigest = password;
	}

	public String getSessionCode() {
		return sessionCode;
	}

	public void setSessionCode(String sessionCode) {
		this.sessionCode = sessionCode;
	}

	public Date getLastAccessDate() {
		return lastAccessDate;
	}

	public void setLastAccessDate(Date lastAccessDate) {
		this.lastAccessDate = lastAccessDate;
	}

	public Date getJoinedOnDate() {
		return joinedOnDate;
	}

	public void setJoinedOnDate(Date joinedOnDate) {
		this.joinedOnDate = joinedOnDate;
	}

	public Date getLastPublishedDate() {
		return lastPublishedDate;
	}

	public void setLastPublishedDate(Date lastPublishedDate) {
		this.lastPublishedDate = lastPublishedDate;
	}

	public Long getLastPublishedVersionId() {
		return lastPublishedVersionId;
	}

	public void setLastPublishedVersionId(Long lastPublishedVersionId) {
		this.lastPublishedVersionId = lastPublishedVersionId;
	}

	public Date getLastPublishedOlderVersionDate() {
		return lastPublishedOlderVersionDate;
	}

	public void setLastPublishedOlderVersionDate(
			Date lastPublishedOlderVersionDate) {
		this.lastPublishedOlderVersionDate = lastPublishedOlderVersionDate;
	}

	public Long getLastPublishedOlderVersionId() {
		return lastPublishedOlderVersionId;
	}

	public void setLastPublishedOlderVersionId(Long lastPublishedOlderVersionId) {
		this.lastPublishedOlderVersionId = lastPublishedOlderVersionId;
	}

	public Thought getDraft() {
		return draft;
	}

	public void setDraft(Thought draft) {
		this.draft = draft;
	}

	public HashSet<Long> getReads() {
		return reads;
	}

	public void setReads(HashSet<Long> reads) {
		this.reads = reads;
	}

	public HashMap<Long, TagThinker> getTagsByThought() {
		return tagsByThought;
	}

	public void setTagsByThought(HashMap<Long, TagThinker> tagsByThought) {
		this.tagsByThought = tagsByThought;
	}

	public ArrayList<Thought> getActiveReferences() {
		return activeReferences;
	}

	public void setActiveReferences(ArrayList<Thought> activeReferences) {
		this.activeReferences = activeReferences;
	}

	public ArrayList<Thought> getDraftReferences() {
		return draftReferences;
	}

	public void setDraftReferences(ArrayList<Thought> draftReferences) {
		this.draftReferences = draftReferences;
	}

	public SortedSet<Thought> getThoughtsCronologically() {
		return thoughtsCronologically;
	}

	public void setThoughtsCronologically(
			SortedSet<Thought> thoughtsCronologically) {
		this.thoughtsCronologically = thoughtsCronologically;
	}

	// public Ref<IdCache> getRecentPublishedThoughtIds() {
	// return recentPublishedThoughtIds;
	// }
	//
	// public void setRecentPublishedThoughtIds(
	// Ref<IdCache> recentPublishedThoughtIds) {
	// this.recentPublishedThoughtIds = recentPublishedThoughtIds;
	// }
	//
	// public Ref<IdCache> getRecentUnpublishedThoughtIds() {
	// return recentUnpublishedThoughtIds;
	// }
	//
	// public void setRecentUnpublishedThoughtIds(
	// Ref<IdCache> recentUnpublishedThoughtIds) {
	// this.recentUnpublishedThoughtIds = recentUnpublishedThoughtIds;
	// }

}
